var app = getApp();
var WxParse = require('../../wxParse/wxParse.js');
Page({
	data: {
	list:null,
  goods_name:null,
  order_id:0,
  order_status:0,
  order_amount:0,//应付款金额
  total_amount:0,//订单总价
  use_code:null,
  use_code_show:true,
  order_status:0,
  order_status_name:null,
  order_is_share:0,
  goods_content: null,
  order_status:0,
  order_qrcode:'',

  order_status_list: null,
  tab_index: 0,
  slider_offset: 0,
  slider_left: 0,
  slider_width: 0,
  order_list: []

	},
  //点击订单状态刷新 0商品详情1商家列表
  handleTab: function (event) {
    var that = this
    that.setData({
      slider_offset: event.currentTarget.offsetLeft,
      tab_index: event.currentTarget.id
    });
    //调用接口
    //Getglist(that, getApp().globalData.openid, event.currentTarget.id)

  },
  onLoad: function (options) {
    this.setData({
      slider_left: 0,
      slider_offset: this.data.window_width / 2 * this.data.tab_index,
      slider_width: this.data.window_width / 2
    });

    var order_id = options.id;
    var that = this
    console.log('订单id='+order_id);
    //获取订单详情
    wx:wx.request({
      url: 'https://17fx.com/weapp/api/orderdetails.html',
      data: {
        order_id:order_id
      },
      header: { 'content-type': 'application/json'},
      success: function(res) {
        console.log(res.data)
        var article = res.data.goods_content;
        WxParse.wxParse('goods_content', 'html', article, that, 5);
        that.setData({
          list: res.data.suppliers,
          goods_name: res.data.goods_name,
          order_id:res.data.order_id,
          order_amount: res.data.order_amount,
          total_amount: res.data.total_amount,
          use_code:res.data.use_code,
          order_status:res.data.order_status,
          order_is_share:res.data.is_share,
          //goods_content:tab1,
          order_qrcode: res.data.order_qrcode
        })
        if (res.data.use_code == '') {
          that.setData({
            use_code_show:false
          })
        }
        if(res.data.order_status == 0 ){
          that.setData({
            order_status_name:'代付款',
            order_status:0
          })
        } else if (res.data.order_status == 1) {
          that.setData({
            order_status_name: '待使用',
            order_status: 1
          })
        } else if (res.data.order_status == 2) {
          that.setData({
            order_status_name: '已完成',
            order_status: 2
          })
        } else if (res.data.order_status == 3) {
          that.setData({
            order_status_name: '已取消',
            order_status: 3
          })
        }
      },
      fail: function(res) {},
      complete: function(res) {},
    })
	},
	onShow: function () {
	},
	onScroll: function (e) {

	},
	tapSearch: function () {

	},
	toNearby: function () {

	},
	tapFilter: function () {

	},
	tapBanner: function () {

	}
});

